<template>
	<div class="Icons">
		<swiper :options="swiperOption">
			<swiper-slide v-for='(page, index) of pages' :key='index'>
					<div class="icons-content" v-for='item in page'>
						<div class="icons-img">
							<img :src="item.imgUrl" class="icons-img-size" />
						</div>
						<p class="text">{{item.desc}}</p>
					</div>
			</swiper-slide>
			
		</swiper>
	</div>
</template>

<script>
export default {
	name: 'HomeIcons',
	props: {
		iconList: Array
	},
	data () {
		return {
			swiperOption: {
				autoplay: false
			}
		}
	},
	computed: {
		pages() {
			const pages = []
			this.iconList.forEach((item, index) => {
				const page = Math.floor(index / 8)
				if(!pages[page]){
					pages[page] = []
				}
				pages[page].push(item)
			})
			return pages
		}
	}
}	
</script>

<style lang="stylus" scoped>
@import '~styles/mixins.styl'
	.Icons >>> .swiper-container
		width: 100%
		height: 0
		padding-bottom: 50%
		margin-top: .2rem
	.icons-content
		position: relative
		overflow: hidden
		float: left
		width: 25%
		height: 0
		padding-bottom: 25%
		.icons-img
			width: 100%
			position: absolute
			top: 0
			left: 0
			right:0
			bottom: .77rem
			.icons-img-size
				display: block
				height: 100%
				margin: 0 auto	
		.text
			width: 100%
			position: absolute
			bottom: 0
			height: .77rem
			line-height: .77rem
			text-align: center
			ellipsis()
</style>